/*
 * @Author: actor
 * @Date: 2023-12-18 17:33:28
 * @email: 395593455@qq.com
 * @LastEditors: actor
 * @LastEditTime: 2023-12-18 17:33:42
 * @FilePath: \i-hos-app\shared\emr\src\utils\timestamp.ts
 * @Description:
 */
// 时间转换(年月日)
export const timestamp = (timestamp: Date | string): string => {
  let date: Date = new Date(timestamp)
  let Y: string = date.getFullYear() + '-'
  let M: string = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  let D: string | number = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  return Y + M + D
}

// 时间转换(年月日 时分秒)
export const timestampToTime = (timestamp: Date | string): string => {
  let date: Date = new Date(timestamp)
  let Y: string = date.getFullYear() + '-'
  let M: string = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  let D: string = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
  let h: string = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
  let m: string = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
  let s: string | number = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  return Y + M + D + h + m + s
}
